package com.example.ldachu.testdownload.http.util;

import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * @author zxKueen on 2017-12-25 10:56
 *         Email: 4994766@qq.com
 *         rxjava相关的工具类
 */

public class RxUtil {

    /**
     * 用于线程切换
     * @return
     */
  public static ObservableTransformer schedulers() {
        return new ObservableTransformer() {

            @Override
            public ObservableSource apply(Observable upstream) {
                return upstream.subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread());
            }
        };
    }

}
